<%--
  Created by IntelliJ IDEA.
  User: bwj
  Date: 2021/6/23
  Time: 15:27
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <base href="<%=basePath%>">

    <title>
        站点查询修改
    </title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="css/main.css" media="all">
    <script type="text/javascript" src="lib/loading/okLoading.js"></script>
    <link rel="stylesheet" href="css/bootstrap.css">
    <script src="<%=basePath%>js/jquery.min.js" ></script>
    <link rel="stylesheet" href="fenye/myPagination.css">
    <script src="fenye/myPagination.js"></script>

</head>

<body>
<div class="x-nav">
            <span class="layui-breadcrumb">
              <a><cite>首页</cite></a>
              <a><cite>订单管理</cite></a>
              <a><cite>站点查询修改</cite></a>
            </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"  href="javascript:location.replace(location.href);" title="刷新"><i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body">
    <form class="layui-form x-center" action="site/query" method="post" style="width:100%">
        <div class="layui-form-pane" style="margin-top: 15px;">
            <div class="layui-form-item">
                <label class="layui-form-label" style="width: 100px;">ID</label>
                <div class="layui-input-inline">
                    <input type="text" name="siteId" id="siteId" value="${qp.siteId}"   class="layui-input">
                </div>
                <label class="layui-form-label" style="width: 100px;">站点</label>
                <div class="layui-input-inline">
                    <input type="text" name="zhandian" id="zhandian" value="${qp.zhandian}"   class="layui-input">
                </div>
                <label class="layui-form-label" style="width: 100px;">省</label>
                <div class="layui-input-inline">
                    <input type="text" name="sheng" id="sheng" value="${qp.sheng }"   class="layui-input">
                </div>

                <label class="layui-form-label" style="width: 100px;">市</label>

                <div class="layui-input-inline">
                    <input type="text" name="shi" value="${qp.shi }" id="shi"   class="layui-input">
                </div>

                <div class="layui-input-inline" style="width:80px">
                    <button class="layui-btn"  type="submit" ><i class="layui-icon">&#xe615;</i></button>
                </div>
            </div>
        </div>
    </form>
    <xblock>
        <button class="layui-btn" >
            查询结果
        </button>
        <span class="x-right" style="line-height:40px">共有数据：${qp.count} 条</span>
    </xblock>
    <table class="layui-table">
        <thead>
        <tr>
            <th>
               站点ID
            </th>
            <th>
                站点名
            </th>
            <th>
                省
            </th>
            <th>
                市
            </th>
            <th>
                操作
            </th>
        </tr>
        </thead>
        <tbody id="ches">
        <c:forEach items="${siteList}" var="s">
        <tr>
            <td>
               ${s.siteId}
            </td>
            <td>
                   ${s.siteName}
            </td>
            <td>
                    ${s.province}
            </td>
            <td>
                    ${s.city}
            </td>
            <td class="td-manage">
                <a title="编辑" href="javascript:;" onclick="activity_edit('编辑','site/site_details','${s.siteId}','1000','600')"
                   class="ml-5" style="text-decoration:none">
                    <i class="layui-icon">&#xe642;</i>
                </a>
                <a title="删除" href="javascript:;" onclick="activity_del(this,'${s.siteId}')"
                   style="text-decoration:none">
                    <i class="layui-icon">&#xe640;</i>
                </a>
            </td>
        </tr>
        </c:forEach>

        </tbody>
        <tr>
            <td colspan="11" align="center">

                当前页数：${qp.page }&nbsp;&nbsp;&nbsp;&nbsp;
                <a onclick="fenye(1)">首页</a>&nbsp;&nbsp;&nbsp;&nbsp;
                <a onclick="fenye(${qp.shangPage})">上一页</a>&nbsp;&nbsp;&nbsp;&nbsp;
                <a onclick="fenye(${qp.xiaPage})">下一页</a>&nbsp;&nbsp;&nbsp;&nbsp;
                <a onclick="fenye(${qp.pageCount})">尾页</a>&nbsp;&nbsp;&nbsp;&nbsp;
                总页数：${qp.pageCount }
            </td>
        </tr>
        <tr>
            <td colspan="11" align="center">
                <div id="pagination" class="pagination"></div>
                <script>
                    window.onload=function () {
                        new myPagination({

                            id:'pagination',
                            curPage : ${qp.page},//初始页
                            pageTotal : ${qp.pageCount},//总页数
                            pageAmount : 3,//每页多少条
                            dataTotal : ${qp.count},//总共多少条数据
                            pageSize : 3,//可选，分页个数
                            showPageTotalFlag : true,//是否显示数据统计
                            showSkipInputFlag : true,//是否支持跳转
                            getPage : function(page) {
                                //获取当前页数
                                console.log(page);
                                fenye(page);
                            }

                        })

                    }
                </script>
            </td>
        </tr>
    </table>

    <div id="page"></div>
</div>
<script src="lib/layui/layui.js" charset="utf-8"></script>
<script src="js/x-layui.js" charset="utf-8"></script>
<script>
    layui.use(['laydate','element','laypage','layer'], function(){
        $ = layui.jquery;//jquery
        laydate = layui.laydate;//日期插件
        lement = layui.element();//面包导航
        laypage = layui.laypage;//分页
        layer = layui.layer;//弹出层
        okLoading.close($);
        //以上模块根据需要引入


        var start = {
            min: '1999-06-16 23:59:59'
            ,max: '2099-06-16 23:59:59'
            ,istoday: false
            ,choose: function(datas){
                end.min = datas; //开始日选好后，重置结束日的最小日期
                end.start = datas //将结束日的初始值设定为开始日
            }
        };

        var end = {
            min: laydate.now()
            ,max: '2099-06-16 23:59:59'
            ,istoday: false
            ,choose: function(datas){
                start.max = datas; //结束日选好后，重置开始日的最大日期
            }
        };

        document.getElementById('LAY_demorange_s').onclick = function(){
            start.elem = this;
            laydate(start);
        }
        document.getElementById('LAY_demorange_e').onclick = function(){
            end.elem = this
            laydate(end);
        }
    });


    function question_show (argument) {
        layer.msg('可以跳到前台具体问题页面',{icon:1,time:1000});
    }

    //编辑
    function activity_edit (title,url,id,w,h) {
        url = url+"/"+id;
        x_admin_show(title,url,w,h);
    }

    /*删除*/
    function activity_del(obj,id){
        layer.confirm('确认要删除吗？',{icon:3,title:'提示信息'},function(index){
            $.ajax({
                type:"post",
                url:"site/delete",
                data:{id:id},
                dataType:"json",
                success:function(data){
                    var i=parseInt(data);
                    if(i==1){
                        //发异步删除数据
                        $(obj).parents("tr").remove();
                        layer.msg(i.info,{icon:6,time:1000});
                        setTimeout(function(){
                            window.location.reload();
                        },1000);return false;
                    } else{
                        layer.msg(i.info,{icon:5,time:1000});return false;
                    }
                }
            });
            //发异步删除数据
            $(obj).parents("tr").remove();
            layer.msg('已删除!',{icon:1,time:1000});
        });
    }
</script>
<script type="text/javascript">
    function fenye(page) {

        var siteId=$('#siteId').val();
        var zhandian=$('#zhandian').val();
        var sheng=$('#sheng').val();
        var shi=$('#shi').val();
        if (siteId==""){
            siteId="!";
        }
        if (zhandian==""){
            zhandian="!";
        }
        if (sheng==""){
            sheng="!";
        }
        if (shi==""){
            shi="!";
        }
        var url="site/"+page+"/"+siteId+"/"+zhandian+"/"+sheng+"/"+shi+"/fenye";
        location=url;
    }

</script>
</body>
</html>